package com.jacklin.account.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jacklin.account.domain.Account;
import com.jacklin.account.dto.OrderPayDTO;
import com.jacklin.account.mapper.AccountMapper;
import com.jacklin.account.service.AccountService;
import org.jacklin.common.api.vo.Result;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * AccountService服务实现类
 *
 * @author: jacklin
 * @since: 2022/3/26 14:25
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements AccountService {

    /**
     * 用户购买商品下单
     * 1.调用商品服务判断商品是否还剩库存
     * 2.判断用户的账户余额是否大于商品的价格
     * 3.锁定库存
     * 4.下单
     * 5.下单成功，扣减库存
     **/
    @Override
    public Result<?> orderPay(OrderPayDTO orderPayDTO) {
        return null;
    }

    @Override
    public Boolean decrease(Integer userId, Integer accountId, BigDecimal money) {
        return baseMapper.decrease(userId, accountId, money);
    }
}
